<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@include file="/view/common/header-company.jspf" %>
	
	<center>
		<h1>企业修改密码</h1>
	</center>
	   <c:if test="${!empty param.oldpasswordError }">
        <div class="alert alert-danger alert-dismissible fade in" role="alert"
            style="text-align: center;">
            <button type="button" class="close" data-dismiss="alert"
                aria-label="Close">
                <span aria-hidden="true">×</span>
            </button>
            <strong>原密码错误！</strong>
        </div>
    </c:if>
      <c:if test="${!empty param.repasswordError }">
        <div class="alert alert-danger alert-dismissible fade in" role="alert"
            style="text-align: center;">
            <button type="button" class="close" data-dismiss="alert"
                aria-label="Close">
                <span aria-hidden="true">×</span>
            </button>
            <strong>新密码重复输入不同！</strong>
        </div>
    </c:if>
	<div class="container">
	<form class="form-horizontal" role="form"
		action="<%=request.getContextPath()%>/CompanyServlet?command=updatePassword" method="post" onsubmit="return validate();">
		<div class="form-group">
		<label for="name" class="col-sm-2 control-label" style="margin-left:-80px;">code</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="code"
					placeholder="code" id="code"  disabled="disabled" value="${sessionScope.company.code }">
			</div>
		<span id="codeInfo" class="bg-danger text-muted"></span>
		</div>
		<div class="form-group">
		<label for="name" class="col-sm-2 control-label" style="margin-left:-80px;">原密码</label>
			<div class="col-sm-10">
				<input type="password" class="form-control" name="oldPassword" id="oldPassword">
			</div>
		<span id="pwdInfo1" class="bg-danger text-muted"></span>
		</div>
		<div class="form-group">
		<label for="name" class="col-sm-2 control-label" style="margin-left:-80px;">新的密码</label>
			<div class="col-sm-10">
				<input type="password" class="form-control" name="newPassword" id="newPassword">
			</div>
		<span id="pwdInfo2" class="bg-danger text-muted"></span>
		</div>
		<div class="form-group">
		<label for="name" class="col-sm-2 control-label" style="margin-left:-80px;">确认密码</label>
			<div class="col-sm-10">
				<input type="password" class="form-control" name="rePassword" id="rePassword">
			</div>
		<span id="pwdInfo3" class="bg-danger text-muted"></span>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10"">
				<button type="submit" class="btn btn-default">修改</button>
				 <input type="button" class="btn btn-primary" onclick="javascript:history.back();" value="返回"/>
			</div>
		</div>
	</form>
	</div>
	<script>
			/**
			 * 表单验证
			 */
			function validate() {
				var result = true;
				var oldPassword = document.getElementById("oldPassword");
				var newPassword = document.getElementById("newPassword");
				var rePassword = document.getElementById("rePassword");
				if(oldPassword.value == ''){
					document.getElementById("pwdInfo1").innerHTML="原密码不能为空";
					result = false;
				}else{
					document.getElementById("pwdInfo1").innerHTML="";
				}
				if(newPassword.value == ''){
					document.getElementById("pwdInfo2").innerHTML="新密码不能为空";
					result = false;
				}else{
					document.getElementById("pwdInfo2").innerHTML="";
				}
				if(rePassword.value == ''){
					document.getElementById("pwdInfo3").innerHTML="新密码不能为空";
					result = false;
				}else{
					document.getElementById("pwdInfo3").innerHTML="";
				}
				
				return result;
			}
			/**
			*el获取是否修改成功信息(相当于request.getParameter(arg0))
			*/
			if('${param.updateSuccess}'){
				layer.msg('修改成功！',{icon:1});
			}
			if('${param.updateError}'){
				layer.msg('修改失败！',{icon:0});
			}
			
		</script>
</body>
</html>